package StudyCode.summary.mycollection;

import java.util.Map;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CopiesEntryFromMapToMap {
	public static <A, B> void updateMapAndRemoveNulls(Map<A, B> source,
	                                                  Map<A, B> target) {

		assert source != target;
		for (Map.Entry<A, B> entry : source.entrySet()) {
			A key = entry.getKey();
			B value = entry.getValue();
			if (value != null) {
				target.put(key, value);
			} else {
				target.remove(key);
			}
		}
	}
}
